package JavaStudy.ReentrantReadWriteLockDemo;

import lombok.extern.slf4j.Slf4j;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author welsir
 * @version 1.0
 * @description: TODO
 * @date 2022/11/1 22:00
 */
@Slf4j
public class LRUCache<K, V> extends LinkedHashMap<K, V> {
    private int cap;
    private static final long serialVersionUID = 1L;

    public LRUCache(int cap) {
        super(16, 0.75f, true);
        this.cap = cap;
    }

    @Override
    protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
        return size() > cap;
    }
}
